{extend name="../../../view/public/base" /}

{block name="css"}
<style>
    body {
        background-color: #F2F2F2;
    }
</style>
{/block}

{block name="body"}
<div style="padding: 20px; background-color: #F2F2F2;">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card" style="padding: 10px">
                <form class="layui-form" lay-filter="addForm" autocomplete="off">
                    <!--昵称-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">昵称</label>
                        <div class="layui-input-inline">
                            <input type="text" name="nickname" placeholder="请输入昵称" class="layui-input" value="" lay-verify="required">
                        </div>
                    </div>
                    <!--手机号-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">手机号</label>
                        <div class="layui-input-inline">
                            <input type="text" name="mobile" placeholder="请输入手机号" class="layui-input" value="" lay-verify="required|phone|number">
                        </div>
                    </div>
                    <!--密码-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">密码</label>
                        <div class="layui-input-inline">
                            <input type="text" name="password" placeholder="请输入密码" class="layui-input" value="" lay-verify="required">
                        </div>
                    </div>
                    <!--安全密码-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">安全密码</label>
                        <div class="layui-input-inline">
                            <input type="text" name="safe_password" placeholder="请输入安全密码" class="layui-input" value="" lay-verify="required">
                        </div>
                    </div>
<!--                    &lt;!&ndash;应用id&ndash;&gt;
                    <div class="layui-form-item">
                        <label class="layui-form-label">应用id</label>
                        <div class="layui-input-block">
                            <input type="number" name="bind_member_miniapp_id" placeholder="请输入应用id" class="layui-input" value="0">
                        </div>
                    </div>
                    &lt;!&ndash;上级id&ndash;&gt;
                    <div class="layui-form-item">
                        <label class="layui-form-label">上级id</label>
                        <div class="layui-input-block">
                            <input type="number" name="parent_id" placeholder="请输入上级id" class="layui-input" value="0">
                        </div>
                    </div>
                    &lt;!&ndash;头像&ndash;&gt;
                    <div class="layui-form-item">
                        <label class="layui-form-label">头像</label>
                        <div class="layui-input-block">
                            <input type="hidden" name="avatar" class="layui-input">
                            <div class="layui-upload">
                                <button type="button" class="layui-btn layui-btn-normal" id="avatar">上传单图</button>
                                <div class="layui-upload-list" id="avatarPreview" style="display: flex;">
                                    &lt;!&ndash;加载默认图片&ndash;&gt;
                                    <script>
                                        getImagesHtmlForEdit('', 'avatar')
                                    </script>
                                </div>
                            </div>
                        </div>
                    </div>
                    &lt;!&ndash;用户名&ndash;&gt;
                    <div class="layui-form-item">
                        <label class="layui-form-label">用户名</label>
                        <div class="layui-input-block">
                            <input type="text" name="username" placeholder="请输入用户名" class="layui-input" value="">
                        </div>
                    </div>
                    &lt;!&ndash;状态:0=正常,1=冻结&ndash;&gt;
                    <div class="layui-form-item">
                        <label class="layui-form-label">状态</label>
                        <div class="layui-input-inline" id="is_lock">
                            <select name="is_lock" lay-verify="required">
                                <option value="" >请选择状态</option>
                                    <option value="0" selected>正常</option>
                                    <option value="1">冻结</option>
                            </select>
                        </div>
                    </div>
                    &lt;!&ndash;配置权限:0=开启,1=关闭&ndash;&gt;
                    <div class="layui-form-item">
                        <label class="layui-form-label">配置权限</label>
                        <div class="layui-input-inline" id="lock_config">
                            <select name="lock_config" lay-verify="required">
                                <option value="" >请选择配置权限</option>
                                    <option value="0" selected>开启</option>
                                    <option value="1">关闭</option>
                            </select>
                        </div>
                    </div>
                    &lt;!&ndash;登录ip&ndash;&gt;
                    <div class="layui-form-item">
                        <label class="layui-form-label">登录ip</label>
                        <div class="layui-input-block">
                            <input type="text" name="login_ip" placeholder="请输入登录ip" class="layui-input" value="">
                        </div>
                    </div>
                    &lt;!&ndash;登录时间&ndash;&gt;
                    <div class="layui-form-item">
                        <label class="layui-form-label">登录时间</label>
                        <div class="layui-input-inline">
                            <input id='login_time'  type='text' name='login_time' placeholder='请输入登录时间' class='layui-input'>
                            &lt;!&ndash;格式化时间&ndash;&gt;
                            <script>
                                formatDate("", 'login_time')
                            </script>
                        </div>
                    </div>-->

                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="submitBtn">立即提交</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

{/block}

{block name="js"}
<script>
    var layer, form, bwajax, upload, $, laydate;

    layui.use(['layer', 'form', 'bwajax', 'upload', 'laydate'], function () {
        layer = layui.layer;
        form = layui.form;
        bwajax = layui.bwajax.instance();
        upload = layui.upload;
        $ = layui.jquery;
        laydate = layui.laydate;

        //头像单图上传
        bw_upload(upload, 'avatar', 'image');
        //登录时间 日期时间选择器
        laydate.render({
            elem: '#login_time'
            ,type: 'datetime'
        });


        //监听提交按钮
        form.on('submit(submitBtn)', function (obj) {
            data = obj.field;

            //时间转为时间戳
            // data.login_time = Date.parse(data.login_time) / 1000;


            //ajax调用后台接口
            bwajax.post("{:Url('add')}", data)
                .then(function (response) {
                    if (response.data.data.errcode === 0) {
                        layer.msg('提交成功', {icon: 1});
                        submitSuccess();
                    } else {
                        layer.msg(response.data.msg, {icon: 2});
                    }
                })

            return false;
        })
    });
</script>
{/block}